package c1703;

import java.io.PrintWriter;
import java.util.Scanner;
 
public class G {
    static Scanner cin = new Scanner(System.in);
    static PrintWriter cout = new PrintWriter(System.out);
    static int[] a = new int[10];
 
    static {
        a[0] = a[1] = 1;
        for (int i = 2; i < a.length; i++) a[i] = i * a[i - 1];
    }
 
    static boolean greedy(int n) {
        for (int i = a.length - 1; i >= 1; i--) {
            if (n >= a[i]) n -= a[i];
        }
        return n == 0;
    }
 
    public static void main(String[] args) {
        for (int m = cin.nextInt(); m-- > 0; ) {
            if (greedy(cin.nextInt())) {
                cout.println("Yes");
            }else{
                cout.println("No");
            }
        }
        cin.close();
        cout.close();
    }
}